<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:t="http://www.pagac.cz/jsf">
 <h:head></h:head>
 <h:body>
    <ui:composition template="/WEB-INF/templates/template-insystem.xhtml">

        <!-- Toolbar -->
        <ui:define name="toolbar-place">
            <t:toolbar>
                <t:icon iconName="home" action="goHome" label="#{msgs['toolbar.home']}" />
                <t:icon iconName="back" action="customer/list" label="#{msgs['toolbar.back']}" />
                <t:icon iconName="print" action="printPage" label="#{msgs['toolbar.print']}" />
            </t:toolbar>
        </ui:define>

       <ui:define name="content-title">
           <h1>#{msgs["editCustomer.page-title"]}</h1>
       </ui:define>

        <ui:define name="content">
            <c:if test="#{customerManager.customer.idUser == -1}">
                <script language="JavaScript">
                   window.location="list.jsf";
                </script>
            </c:if>
            <p>
              #{msgs["register.welcome-text"]}
            </p>

            <div>
                    <fieldset>
                        <legend>#{msgs["customer.customerValues"]}</legend>
                         <h:panelGrid columns="3">
                            <h:outputLabel for="name">#{msgs["customer.name"]} *</h:outputLabel>
                            <h:inputText id="name" maxlength="32" required="true" value="#{customerManager.customer.name}" requiredMessage="#{msgs['customer.requiredName']}">
                                <f:validateLength minimum="3" maximum="32" />
                            </h:inputText>
                            <h:message for="name" />

                            <h:outputLabel for="ic">#{msgs["customer.ic"]}</h:outputLabel>
                            <h:inputText id="ic" maxlength="8" required="false" value="#{customerManager.customer.ic}">
                                <f:validateLength maximum="8" />
                            </h:inputText>
                            <h:message for="ic" />

                            <h:outputLabel for="dic">#{msgs["customer.dic"]}</h:outputLabel>
                            <h:inputText id="dic" maxlength="12" required="false" value="#{customerManager.customer.dic}">
                                <f:validateLength maximum="12" />
                            </h:inputText>
                            <h:message for="dic" />

                          </h:panelGrid>
                    </fieldset>
                    <br/>
                    <fieldset>
                        <legend>#{msgs["customer.contactValues"]}</legend>

                        <h:panelGrid columns="3">
                            <h:outputLabel for="address" >#{msgs["customer.address"]} *</h:outputLabel>
                            <h:inputText id="address" maxlength="32" required="true" value="#{customerManager.customer.address}" requiredMessage="#{msgs['customer.requiredAddress']}">
                                <f:validateLength maximum="32" />
                            </h:inputText>
                            <h:message for="address" />

                            <h:outputLabel for="city">#{msgs["customer.city"]} *</h:outputLabel>
                            <h:inputText id="city" maxlength="32" required="true" value="#{customerManager.customer.city}" requiredMessage="#{msgs['customer.requiredCity']}">
                                <f:validateLength maximum="32" />
                            </h:inputText>
                            <h:message for="city" />

                            <h:outputLabel for="zipCode">#{msgs["customer.zipCode"]} *</h:outputLabel>
                            <h:inputText id="zipCode" maxlength="20" required="true" value="#{customerManager.customer.zipCode}" requiredMessage="#{msgs['customer.requiredZipCode']}">
                                <f:validateLength maximum="20" />
                            </h:inputText>
                            <h:message for="zipCode" />

                            <h:outputLabel for="phone">#{msgs["customer.phone"]}</h:outputLabel>
                            <h:inputText id="phone" maxlength="16" required="false" value="#{customerManager.customer.phone}">
                                <f:validateLength maximum="16" />
                            </h:inputText>
                            <h:message for="phone" />

                            <h:outputLabel for="email">#{msgs["customer.email"]} *</h:outputLabel>
                            <h:inputText id="email" maxlength="64" required="true" value="#{customerManager.customer.email}" validatorMessage="#{msgs['customer.badEmail']}"  requiredMessage="#{msgs['customer.requiredEmail']}">
                                <f:validateLength maximum="64" />
                                <f:validator validatorId="EmailValidator"/>
                            </h:inputText>
                            <h:message for="email" />

                        </h:panelGrid>
                    </fieldset>
                    <br/>
                    <fieldset>
                        <legend>#{msgs["customer.rateValues"]}</legend>

                        <h:panelGrid columns="3">
                            <h:outputLabel for="rateType" >#{msgs["customer.rateType"]} *</h:outputLabel>
                            <h:selectOneMenu id="rateType" value="#{customerManager.customer.rateType}">
                                <f:selectItem itemValue="h" itemLabel="#{msgs['customer.rateType.hours']}"></f:selectItem>
                                <f:selectItem itemValue="t" itemLabel="#{msgs['customer.rateType.tariff']}"></f:selectItem>
                                <f:selectItem itemValue="p" itemLabel="#{msgs['customer.rateType.project']}"></f:selectItem>
                            </h:selectOneMenu>
                            <h:message for="rateType" />

                            <h:outputLabel for="price">#{msgs["customer.pricePerRateUnit"]}</h:outputLabel>
                            <h:inputText id="price" required="false" maxlength="11" value="#{customerManager.customer.pricePerRateUnit}">
                               <f:validateDoubleRange minimum="0"/>
                               <f:convertNumber type="number" maxIntegerDigits="11"/>
                            </h:inputText>
                            <h:message for="price" />
                        </h:panelGrid>
                    </fieldset>
                    <br/>
                    <fieldset>
                        <legend>#{msgs["customer.note"]}</legend>
                        <h:inputTextarea cols="30" rows="4" id="note" required="false" value="#{customerManager.customer.note}"/>
                    </fieldset>
                    <br />
                    <h:commandButton action="#{customerManager.update}" type="submit" value="#{msgs['customer.editSubmit']}"></h:commandButton>
            </div>

       </ui:define>
    </ui:composition>

</h:body>
</html>
